﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

using WHC.Hotel.BLL;

namespace WHC.Hotel.UI.Report
{
    public partial class KFCustomerReport : BaseForm
    {
        public KFCustomerReport()
        {
            InitializeComponent();
        }

        private void FrmKFCustomer_Load(object sender, EventArgs e)
        {
            InitDictItem();

            this.winGridView1.ProgressBar = this.toolStripProgressBar1.ProgressBar;
            this.winGridView1.AppendedMenu = this.contextMenuStrip1;
        }

        private void InitDictItem()
        {
            this.txtSource.Items.Clear();
            this.txtSource.Items.AddRange(DictItemUtil.GetCustomerSource());
        }

        private void BindData()
        {
            #region 添加别名解析
            this.winGridView1.AddColumnAlias("RoomNo", "房间号");
            this.winGridView1.AddColumnAlias("CompanyName", "公司名称");
            this.winGridView1.AddColumnAlias("Name", "宾客姓名");
            this.winGridView1.AddColumnAlias("Telephone", "联系电话");
            this.winGridView1.AddColumnAlias("Sex", "性别");
            this.winGridView1.AddColumnAlias("IDCarType", "证件类型");
            this.winGridView1.AddColumnAlias("IDNumber", "证件编号");
            this.winGridView1.AddColumnAlias("Source", "宾客来源");
            this.winGridView1.AddColumnAlias("Persons", "人数");
            this.winGridView1.AddColumnAlias("DepositMoney", "押金");
            this.winGridView1.AddColumnAlias("PreLivedDays", "预住天数");
            this.winGridView1.AddColumnAlias("Status", "当前状态");
            this.winGridView1.AddColumnAlias("CreateDate", "进店时间");
            this.winGridView1.AddColumnAlias("CheckOutDate", "离店时间");
            this.winGridView1.AddColumnAlias("BillNumber", "结账单号");
            this.winGridView1.AddColumnAlias("Address", "宾客地址");
            this.winGridView1.AddColumnAlias("Note", "备注");
            #endregion

            DataTable dt = BLLFactory<Customer>.Instance.GetCustomerReport(this.txtContent.Text, this.txtSource.Text, this.checkBox1.Checked);
            this.winGridView1.DataSource = dt.DefaultView;
            this.winGridView1.PrintTitle = Portal.gc.gAppUnit + " -- " + "来宾信息查询报表";
        }

        private void btnSearch_Click(object sender, EventArgs e)
        {
            BindData();

            //item.SubItems.Add("合计:");
            //item.SubItems.Add(string.Format("共{0}条记录", i));
            //item.SubItems.Add(string.Format("人数:{0}", persons));
            //item.SubItems.Add(string.Format("押金:{0}", deposit.ToString("C2")));
        }

        private void txtContent_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                btnSearch_Click(null, null);
            }
        }

        private void menu_Refresh_Click(object sender, EventArgs e)
        {
            BindData();
        }
    }
}
